# https://www.luogu.com.cn/problem/P2347

Initial = readline.split(' ').map(&:to_i)
Accounts=[1,2,3,5,10,20]
$res=[[Initial]]

Maxinum=Accounts.zip(Initial).reduce(0){|prev,pair | prev + pair[0]*pair[1]}

def add_argu(num)
	Accounts.each_with_index.reduce([]) { |prev,pair|
	value,index=*pair
	if num < value
		prev 
	else
		prev | $res[num - value].select{|acc| acc[index] > 0}
								.map{|acc| tmp=acc.clone;tmp[index]-=1;tmp}
	end
	}
end
(1..Maxinum).each{|i| $res[i]=add_argu(i)}

Count = $res.reduce(0){ |prev,this|  this.empty?() ? prev : prev+1} -1

puts Count



